<?php

require_once 'common.php';
require_once 'conn.php';

$db = new DBC();
$sql = "SELECT usercode FROM t_task_record WHERE task = 'REGISTER'";
$data = $db->fetchData($sql);

$sql = "SELECT devicecode FROM t_device WHERE email IS NOT NULL AND nickname IS NOT NULL AND password IS NOT NULL";
$users = $db->fetchData($sql);
for ($i = 0; $i < count($users); $i++) {
    for ($j = 0; $j < count($data); $j++) {
        if ($data[$j]['usercode'] == $users[$i]['devicecode']) {
            $users[$i]['has'] = 1;
            break;
        }
    }
}
$array = array();
for ($i = 0; $i < count($users); $i++) {
    if (!isset($users[$i]['has'])) {
        array_push($array, $users[$i]['devicecode']);
    }
}
var_dump($array);
for ($i = 0; $i < count($array); $i++) {
    $sql = "INSERT INTO t_task_record(usercode,task,createTime) VALUES('" . $array[$i]. "','REGISTER',now())";
    $db->execute($sql);
    echo $sql;
}
?>
